/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author USER
 */
@Entity
@Table(name = "JoinContest", catalog = "WebPhotoShare", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "JoinContest.findAll", query = "SELECT j FROM JoinContest j"),
    @NamedQuery(name = "JoinContest.findByIdRegUser", query = "SELECT j FROM JoinContest j WHERE j.idRegUser = :idRegUser"),
    @NamedQuery(name = "JoinContest.findByRegStatus", query = "SELECT j FROM JoinContest j WHERE j.regStatus = :regStatus")})
public class JoinContest implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "IdRegUser", nullable = false)
    private Integer idRegUser;
    @Basic(optional = false)
    @Column(name = "RegStatus", nullable = false)
    private boolean regStatus;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "joinContest")
    private Collection<ImageContest> imageContestCollection;
    @JoinColumn(name = "Username", referencedColumnName = "Username", nullable = false)
    @ManyToOne(optional = false)
    private RegisteredUser registeredUser;
    @JoinColumn(name = "IdContest", referencedColumnName = "IdContest", nullable = false)
    @ManyToOne(optional = false)
    private CreatesContest createsContest;

    public JoinContest() {
    }

    public JoinContest(Integer idRegUser) {
        this.idRegUser = idRegUser;
    }

    public JoinContest(Integer idRegUser, boolean regStatus) {
        this.idRegUser = idRegUser;
        this.regStatus = regStatus;
    }

    public Integer getIdRegUser() {
        return idRegUser;
    }

    public void setIdRegUser(Integer idRegUser) {
        this.idRegUser = idRegUser;
    }

    public boolean getRegStatus() {
        return regStatus;
    }

    public void setRegStatus(boolean regStatus) {
        this.regStatus = regStatus;
    }

    public Collection<ImageContest> getImageContestCollection() {
        return imageContestCollection;
    }

    public void setImageContestCollection(Collection<ImageContest> imageContestCollection) {
        this.imageContestCollection = imageContestCollection;
    }

    public RegisteredUser getRegisteredUser() {
        return registeredUser;
    }

    public void setRegisteredUser(RegisteredUser registeredUser) {
        this.registeredUser = registeredUser;
    }

    public CreatesContest getCreatesContest() {
        return createsContest;
    }

    public void setCreatesContest(CreatesContest createsContest) {
        this.createsContest = createsContest;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRegUser != null ? idRegUser.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof JoinContest)) {
            return false;
        }
        JoinContest other = (JoinContest) object;
        if ((this.idRegUser == null && other.idRegUser != null) || (this.idRegUser != null && !this.idRegUser.equals(other.idRegUser))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "server.entity.JoinContest[idRegUser=" + idRegUser + "]";
    }

}
